package com.multithreading.algorithm;

/**
 * @author zx
 * @version 1.0
 * @package_name: com.multithreading.algorithm
 * @date 2024/6/19 15:48
 */
public class Array_test003 {
    public static void main(String[] args) {
        // 杨辉三角
        int[][] arr = new int[10][];
        // 使用循环 初始化外层数组元素
        for (int i = 0; i < arr.length; i++) {
            arr[i] = new int[i + 1];
            // 给数组元素赋值
            // 给数组每行的首末元素赋值1
            arr[i][0]=1;
            arr[i][i]=1;
            for (int j = 1; j < i; j++) {
                arr[i][j] = arr[i - 1][j - 1] + arr[i - 1][j];
            }
        }

        // 遍历二维数组
        for (int[] into : arr) {
            for (int anInt : into) {
                System.out.print(anInt + "\t");
            }
            System.out.println();
        }

    }
}
